commonlibsse_ng\re\h/
hkbCharacter.rs

1use crate::re::hkArray::hkArray;
2use crate::re::hkRefPtr::hkRefPtr;
3use crate::re::hkRefVariant::hkRefVariant;
4use crate::re::hkReferencedObject::hkReferencedObject;
5use crate::re::hkReferencedObject::hkReferencedObjectVtbl;
6use crate::re::hkStringPtr::hkStringPtr;
7use crate::re::hkbBehaviorGraph::hkbBehaviorGraph;
8use crate::re::hkbCharacterSetup::hkbCharacterSetup;
9use crate::re::hkbProjectData::hkbProjectData;
10use crate::re::hkbRagdollDriver;
11use crate::re::offsets_rtti::RTTI_hkbCharacter;
12use crate::re::offsets_vtable::VTABLE_hkbCharacter;
13use crate::rel::id::VariantID;
14
15/// Represents a character in the Havok behavior system.
16///
17/// Inherits from `hkReferencedObject` and contains data for character setup, behavior, and physics.
18#[repr(C)]
19#[derive(Debug)]
20pub struct hkbCharacter {
21    /// Base class `hkReferencedObject`.
22    pub __base: hkReferencedObject,
23
24    /// Array of pointers to nearby characters.
25    /// - Offset: 0x10
26    pub nearbyCharacters: hkArray<*mut hkbCharacter>,
27
28    /// Current level of detail.
29    /// - Offset: 0x20
30    pub currentLOD: i16,
31
32    /// Number of tracks in the current LOD.
33    /// - Offset: 0x22
34    pub numTracksInLOD: i16,
35
36    /// Padding for alignment.
37    /// - Offset: 0x24
38    pub pad24: u32,
39
40    /// Character name.
41    /// - Offset: 0x28
42    pub name: hkStringPtr,
43
44    /// Reference to the ragdoll driver.
45    /// - Offset: 0x30
46    pub ragdollDriver: hkRefPtr<hkbRagdollDriver>,
47
48    /// Character controller driver.
49    /// - Offset: 0x38
50    pub characterControllerDriver: hkRefVariant,
51
52    /// Foot inverse kinematics driver.
53    /// - Offset: 0x40
54    pub footIkDriver: hkRefVariant,
55
56    /// Hand inverse kinematics driver.
57    /// - Offset: 0x48
58    pub handIkDriver: hkRefVariant,
59
60    /// Character setup reference.
61    /// - Offset: 0x50
62    pub setup: hkRefPtr<hkbCharacterSetup>,
63
64    /// Behavior graph reference.
65    /// - Offset: 0x58
66    pub behaviorGraph: hkRefPtr<hkbBehaviorGraph>,
67
68    /// Project data reference.
69    /// - Offset: 0x60
70    pub projectData: hkRefPtr<hkbProjectData>,
71
72    /// Animation binding set.
73    /// - Offset: 0x68
74    pub animationBindingSet: hkRefVariant,
75
76    /// Raycast interface.
77    /// - Offset: 0x70
78    pub raycastInterface: hkRefVariant,
79
80    /// World reference.
81    /// - Offset: 0x78
82    pub world: hkRefVariant,
83
84    /// Event queue.
85    /// - Offset: 0x80
86    pub eventQueue: hkRefVariant,
87
88    /// World-from-model transform.
89    /// - Offset: 0x88
90    pub worldFromModel: hkRefVariant,
91
92    /// Pointer to pose local data (hkSimpleArray<hkRefVariant>).
93    /// - Offset: 0x90
94    pub poseLocal: *const *const (), // Raw pointer to match const void**
95
96    /// Number of pose local entries.
97    /// - Offset: 0x98
98    pub numPoseLocal: i32,
99
100    /// Flag indicating whether to delete worldFromModel.
101    /// - Offset: 0x9C
102    pub deleteWorldFromModel: bool,
103
104    /// Flag indicating whether to delete poseLocal.
105    /// - Offset: 0x9D
106    pub deletePoseLocal: bool,
107
108    /// Padding for alignment.
109    /// - Offset: 0x9E
110    pub pad9E: u16,
111}
112
113// Compile-time memory layout verification
114const _: () = {
115    assert!(core::mem::offset_of!(hkbCharacter, __base) == 0x0);
116    assert!(core::mem::offset_of!(hkbCharacter, nearbyCharacters) == 0x10);
117    assert!(core::mem::offset_of!(hkbCharacter, currentLOD) == 0x20);
118    assert!(core::mem::offset_of!(hkbCharacter, numTracksInLOD) == 0x22);
119    assert!(core::mem::offset_of!(hkbCharacter, pad24) == 0x24);
120    assert!(core::mem::offset_of!(hkbCharacter, name) == 0x28);
121    assert!(core::mem::offset_of!(hkbCharacter, ragdollDriver) == 0x30);
122    assert!(core::mem::offset_of!(hkbCharacter, characterControllerDriver) == 0x38);
123    assert!(core::mem::offset_of!(hkbCharacter, footIkDriver) == 0x40);
124    assert!(core::mem::offset_of!(hkbCharacter, handIkDriver) == 0x48);
125    assert!(core::mem::offset_of!(hkbCharacter, setup) == 0x50);
126    assert!(core::mem::offset_of!(hkbCharacter, behaviorGraph) == 0x58);
127    assert!(core::mem::offset_of!(hkbCharacter, projectData) == 0x60);
128    assert!(core::mem::offset_of!(hkbCharacter, animationBindingSet) == 0x68);
129    assert!(core::mem::offset_of!(hkbCharacter, raycastInterface) == 0x70);
130    assert!(core::mem::offset_of!(hkbCharacter, world) == 0x78);
131    assert!(core::mem::offset_of!(hkbCharacter, eventQueue) == 0x80);
132    assert!(core::mem::offset_of!(hkbCharacter, worldFromModel) == 0x88);
133    assert!(core::mem::offset_of!(hkbCharacter, poseLocal) == 0x90);
134    assert!(core::mem::offset_of!(hkbCharacter, numPoseLocal) == 0x98);
135    assert!(core::mem::offset_of!(hkbCharacter, deleteWorldFromModel) == 0x9C);
136    assert!(core::mem::offset_of!(hkbCharacter, deletePoseLocal) == 0x9D);
137    assert!(core::mem::offset_of!(hkbCharacter, pad9E) == 0x9E);
138    assert!(core::mem::size_of::<hkbCharacter>() == 0xA0);
139};
140
141impl Default for hkbCharacter {
142    fn default() -> Self {
143        Self::new()
144    }
145}
146
147impl hkbCharacter {
148    /// RTTI identifier for this type.
149    pub const RTTI: VariantID = RTTI_hkbCharacter;
150
151    /// Virtual function table addresses.
152    pub const VTABLE: [VariantID; 1] = VTABLE_hkbCharacter;
153
154    /// Creates a new `hkbCharacter` with default values.
155    #[inline]
156    pub fn new() -> Self {
157        Self {
158            __base: hkReferencedObject::new(),
159            nearbyCharacters: hkArray::new(),
160            currentLOD: 0,
161            numTracksInLOD: 0,
162            pad24: 0,
163            name: hkStringPtr::default(),
164            ragdollDriver: hkRefPtr::default(),
165            characterControllerDriver: hkRefVariant::default(),
166            footIkDriver: hkRefVariant::default(),
167            handIkDriver: hkRefVariant::default(),
168            setup: hkRefPtr::default(),
169            behaviorGraph: hkRefPtr::default(),
170            projectData: hkRefPtr::default(),
171            animationBindingSet: hkRefVariant::default(),
172            raycastInterface: hkRefVariant::default(),
173            world: hkRefVariant::default(),
174            eventQueue: hkRefVariant::default(),
175            worldFromModel: hkRefVariant::default(),
176            poseLocal: std::ptr::null(), // Null pointer for const void**
177            numPoseLocal: 0,
178            deleteWorldFromModel: false,
179            deletePoseLocal: false,
180            pad9E: 0,
181        }
182    }
183}
184
185/// Virtual function table for `hkbCharacter`.
186#[repr(C)]
187pub struct hkbCharacterVtbl {
188    pub __base: hkReferencedObjectVtbl,
189
190    /// Unknown function (placeholder).
191    pub Unk_03: fn(this: &mut hkbCharacter),
192
193    /// Unknown function (placeholder).
194    pub Unk_04: fn(this: &mut hkbCharacter),
195}